//
//  DYLeftTableCell.m
//  DYHospital
//
//  Created by 胡金东 on 16/3/24.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "DYLeftTableCell.h"
#import "Masonry.h"


//左边色彩条宽度
//static const CGFloat leftColorViewWidth=3;




@implementation DYLeftTableCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor grayColor];
        //cell没有任何的样式
        self.accessoryType = UITableViewCellAccessoryNone;
        if (self.leftColorView == nil) {
            self.leftColorView = [[UIView alloc]init];
            self.leftColorView.backgroundColor = [UIColor blueColor];
            self.leftColorView.hidden = YES;
            [self.contentView addSubview:self.leftColorView];
            [self.leftColorView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo (self.contentView.mas_left).with.offset (0);
                make.top.mas_equalTo (self.contentView.mas_top).with.offset (0);
                make.bottom.mas_equalTo (self.contentView.mas_bottom).with.offset (0);
               
                
            }];
        }
        if (self.nameLabel == nil) {
            self.nameLabel = [[UILabel alloc]init];
            self.nameLabel.font = [UIFont systemFontOfSize:17];
            self.nameLabel.textAlignment = NSTextAlignmentCenter;
            //与字体一样大小
            [self.nameLabel sizeToFit];
            [self.contentView addSubview:self.nameLabel];
            [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.center.mas_equalTo (self.contentView);
                make.height.mas_equalTo (@44);

            }];
            
        }
        [self addSubview:self.leftColorView];
        [self addSubview:self.nameLabel];
    }
    return self;
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

//是否选中的颜色变化
-(void)setIsLeftSelect:(BOOL)isLeftSelect
{
    _isLeftSelect = isLeftSelect;
    if (_isLeftSelect) {
        self.backgroundColor = [UIColor whiteColor];
        self.nameLabel.textColor = [UIColor greenColor];
        self.leftColorView.hidden = NO;
    }else{
        self.backgroundColor = [UIColor grayColor];
        self.nameLabel.textColor = [UIColor blackColor];
        self.leftColorView.hidden = YES;
    }
    
}

@end
